From e19d9d2e79a622d55c640c25d054f45e0be49950 Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Sun, 17 Jun 2018 10:57:09 -0600 Subject: [PATCH] cleanup whining about validate filter, and add test. (#197) --- reference/empty.gpx | 3 +++ reference/validate_debug.log | 13 +++++++++++++ reference/validate_empty.log | 1 + testo.d/validate.test | 9 +++++++++ validate.cc | 20 ++++++++++---------- 5 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 reference/empty.gpx create mode 100644 reference/validate_debug.log create mode 100644 reference/validate_empty.log create mode 100644 testo.d/validate.test diff --git a/reference/empty.gpx b/reference/empty.gpx new file mode 100644 index 000000000..f82a1f757 --- /dev/null +++ b/reference/empty.gpx @@ -0,0 +1,3 @@ + + + diff --git a/reference/validate_debug.log b/reference/validate_debug.log new file mode 100644 index 000000000..85e4f47e9 --- /dev/null +++ b/reference/validate_debug.log @@ -0,0 +1,13 @@ + +Processing waypts +point ct: 2, waypt_count: 2 + +Processing routes +route 0 ct: 2, waypt_count: 2 +route head ct: 1, route_count: 1 +total route point ct: 2, route_waypt_count: 2 + +Processing tracks +track 0 ct: 2, waypt_count: 2 +track head ct: 1, track_count: 1 +total track point ct: 2, track_waypt_count: 2 diff --git a/reference/validate_empty.log b/reference/validate_empty.log new file mode 100644 index 000000000..72f1000fe --- /dev/null +++ b/reference/validate_empty.log @@ -0,0 +1 @@ +validate:No input diff --git a/testo.d/validate.test b/testo.d/validate.test new file mode 100644 index 000000000..64b8f3a4b --- /dev/null +++ b/testo.d/validate.test @@ -0,0 +1,9 @@ +gpsbabel -i gpx -f ${REFERENCE}/basecamp.gpx -x validate,debug > /dev/null 2> ${TMPDIR}/validate_debug.log +compare ${REFERENCE}/validate_debug.log ${TMPDIR}/validate_debug.log + +# expecting this to fail so call directly rather than via gpsbabel function +${PNAME} -i gpx -f ${REFERENCE}/empty.gpx -x validate,checkempty > /dev/null 2> ${TMPDIR}/validate_empty.log && { + echo "${PNAME} succeeded! (it shouldn't have with this input...)" +} +compare ${REFERENCE}/validate_empty.log ${TMPDIR}/validate_empty.log + diff --git a/validate.cc b/validate.cc index 2aa67434f..8d5d9a4c7 100644 --- a/validate.cc +++ b/validate.cc @@ -85,10 +85,10 @@ validate_process() } waypt_disp_all(validate_point); if (debug) { - fprintf(stderr, "point ct: %d, waypt_count: %d\n", point_ct, waypt_count()); + fprintf(stderr, "point ct: %u, waypt_count: %u\n", point_ct, waypt_count()); } if (!debug && (point_ct != waypt_count())) { - fatal(MYNAME ":Waypoint count mismatch, expected %d, actual %d\n", waypt_count(), point_ct); + fatal(MYNAME ":Waypoint count mismatch, expected %u, actual %u\n", waypt_count(), point_ct); } head_ct = 0; @@ -99,14 +99,14 @@ validate_process() } route_disp_all(validate_head, validate_head_trl, validate_point); if (debug) { - fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count()); - fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count()); + fprintf(stderr, "route head ct: %u, route_count: %u\n", head_ct, route_count()); + fprintf(stderr, "total route point ct: %u, route_waypt_count: %u\n", point_ct, route_waypt_count()); } if (!debug && (head_ct != route_count())) { - fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct); + fatal(MYNAME ":Route count mismatch, expected %u, actual %u\n", route_count(), head_ct); } if (!debug && (point_ct != route_waypt_count())) { - fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct); + fatal(MYNAME ":Total route waypoint count mismatch, expected %u, actual %u\n", route_waypt_count(), point_ct); } head_ct = 0; @@ -117,14 +117,14 @@ validate_process() } track_disp_all(validate_head, validate_head_trl, validate_point); if (debug) { - fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count()); - fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count()); + fprintf(stderr, "track head ct: %u, track_count: %u\n", head_ct, track_count()); + fprintf(stderr, "total track point ct: %u, track_waypt_count: %u\n", point_ct, track_waypt_count()); } if (!debug && (head_ct != track_count())) { - fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct); + fatal(MYNAME ":Track count mismatch, expected %u, actual %u\n", track_count(), head_ct); } if (!debug && (point_ct != track_waypt_count())) { - fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct); + fatal(MYNAME ":Total track waypoint count mismatch, expected %u, actual %u\n", track_waypt_count(), point_ct); } if (checkempty) { -- 2.30.2